@include('admin.public.head')

<div class="ibox-title">
    <h5>課程添加</h5>
</div>

<div class="ibox-content">
    <form class="form-horizontal">

        <div class="form-group">
            <label class="col-sm-3 control-label">課程編號：</label>
            <div class="col-sm-9">
                <input type="text" name="numbering" class="form-control" placeholder="課程編號"
                       value="{{$result->numbering??''}}">
            </div>
        </div>
        <div class="hr-line-dashed"></div>

        <input type="hidden" name="id" value="{{$id??0}}">

        <div class="form-group">
            <div class="col-sm-4 col-sm-offset-3">
                <button class="btn btn-primary do" type="submit">操作</button>
                <a href="/class_numbering" class="btn btn-primary">返回課程編號列表</a>
            </div>
        </div>
    </form>
</div>

<script>

    $('.do').click(function () {
        var form = new FormData();

        var numbering = $('input[name="numbering"]').val();
        var id = $('input[name="id"]').val();


        form.append("numbering", numbering);
        form.append("id", id);

        $.ajax({
            type: 'POST',
            url: '/class_numbering_do',
            dataType: "json",   //返回格式为json
            data: form,
            processData: false,
            contentType: false,
            success: function (data) {

                if (data.status == '1') {
                    var swal_json = {
                        title: data.message,
                        type: "success"
                    }

                    swal(swal_json, function (isConfirm) {
                        window.location.reload();
                    });

                } else {
                    var swal_json = {
                        title: data.message,
                        type: "error"
                    }

                    swal(swal_json, function (isConfirm) {

                    });
                }
            }
        });

        return false;
    });
</script>
